package zozopo.background.operator;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import zozopo.background.operator.operations.LimitedOS;
import zozopo.background.operator.operations.LimitedTB;
import zozopo.background.operator.operations.OperatorlimitedOS;
import zozopo.background.operator.operations.OperatorlimitedTB;
import zozopo.user.operations.UserOS;
import zozopo.user.operations.UserTB;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class DeleteOperatorlimitedAction extends ActionSupport implements Action,SessionAware{
		
		
		//传入参数
		private String email = "";
		private int limitedId;
		
		private Map<Object, Object> session;
		
		//传出参数
		private UserTB user;
		private List<OperatorlimitedTB> userlimitedList;
		
		public void setSession(Map arg0) {
			// TODO Auto-generated method stub
			session = arg0;
		}
		
		public String execute(){
				
				//权限处理
				UserTB userInfo = (UserTB) session.get("userInfo");
				if(userInfo == null){
					return NONE;
				}
				if(!UserOS.userFlagLeve(userInfo, 17, 1)){
					return NONE;
				}//*/
				
				UserOS userOS = new UserOS();
				OperatorlimitedOS userlimitedOS = new OperatorlimitedOS(userOS.getConn());
			
				user = userOS.getUserInfoByEmail(email);
				
				if(userlimitedOS.isExist(email,limitedId)){
					userlimitedOS.delete(email,limitedId);
					//需要输出提示
				}else{
					
					//输出提示
				}
				userlimitedList = userlimitedOS.selectByUserEmail(email);
			
				userOS.releaseConnection();
				return SUCCESS;
				
		}

		

		public String getEmail() {
			return email;
		}

		public void setEmail(String email) {
			this.email = email;
		}

		public UserTB getUser() {
			return user;
		}

		public void setUser(UserTB user) {
			this.user = user;
		}

		

		public int getLimitedId() {
			return limitedId;
		}

		public void setLimitedId(int limitedId) {
			this.limitedId = limitedId;
		}

		public List<OperatorlimitedTB> getUserlimitedList() {
			return userlimitedList;
		}

		public void setUserlimitedList(List<OperatorlimitedTB> userlimitedList) {
			this.userlimitedList = userlimitedList;
		}
}
